package cn.tedu.spring.bean;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
/**
 * @author tune_the last
 * @date 2025/11/6 - 15:12
 *
 * 对象类型的依赖注入；
 * 需求：在USerService类中注入UserDao的对象
 */

@Service
public class UserService {
    @Value("注册业务")
    private String name;
    /*
        Autowired:
        1.自动装配：注入对象或者接口类型的数据
        2.autowired支持三种方法注入
            2.1 属性注入
            2.2 set方法注入
            2.3 构造方法注入
     */
//    @Autowired
    private UserDao userDao;

//    @Autowired
    public UserService(UserDao userDao) {
        this.userDao = userDao;
    }

//    @Autowired
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public String toString() {
        return "UserService{" +
                "name='" + name + '\'' +
                ", userDao=" + userDao +
                '}';
    }
}
